package admin.action.count.createFile;

import java.io.UnsupportedEncodingException;

import teacher.bean.Award;
import tools.StringDate;
import admin.databaseToExcel.PullAwardToExcel;

public class AwardCreateAction {
	
	private Award award;
	private String date2;
	private int direction;

	public Award getAward() {
		return award;
	}
	public void setAward(Award award) {
		this.award = award;
	}
	public String getDate2() {
		return date2;
	}
	public void setDate2(String date2) {
		this.date2 = date2;
	}
	
	
	public int getDirection() {
		return direction;
	}
	public void setDirection(int direction) {
		this.direction = direction;
	}
	public String execute()
	{
		Award awa=new Award();
		if(this.getAward()!=null)
		{
			System.out.println("名称为:"+this.getAward().getName());
			
			if(this.getAward().getName()==null||this.getAward().getName().equals(""))
				this.getAward().setName(null);
			else
			{

					try {
						this.getAward().setName(new String(this.getAward().getName().getBytes("iso-8859-1"),"utf-8"));
					} catch (UnsupportedEncodingException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
			}
			if(this.getAward().getProjectName()==null||this.getAward().getProjectName().equals(""))
				this.getAward().setProjectName(null);
			else
			{
					try {
						this.getAward().setProjectName(new String(this.getAward().getProjectName().getBytes("iso-8859-1"),"utf-8"));
					} catch (UnsupportedEncodingException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
			}
			if(this.getAward().getEmpowerUnit()==null||this.getAward().getEmpowerUnit().equals(""))
				this.getAward().setEmpowerUnit(null);
			else
			{
					try {
						this.getAward().setEmpowerUnit(new String(this.getAward().getEmpowerUnit().getBytes("iso-8859-1"),"utf-8"));
					} catch (UnsupportedEncodingException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
			}
			if(this.getAward().getPeople()==null||this.getAward().getPeople().equals(""))
				this.getAward().setPeople(null);
			else
			{
					try {
						this.getAward().setPeople(new String(this.getAward().getPeople().getBytes("iso-8859-1"),"utf-8"));
					} catch (UnsupportedEncodingException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
			}
			if(this.getAward().getDate()!=null)
				this.getAward().setDate(
						StringDate.StringToDate(
								StringDate.DateToString(
										this.getAward().getDate())));
		if(this.getDate2()!=null&&!this.getDate2().equals(""))	
		 awa.setDate(StringDate.StringToDate(this.getDate2()));
			
		}
		System.out.println("该人的名称为:"+this.getAward().getPeople());
		PullAwardToExcel.awardExcel(3, this.getAward(), awa,this.getDirection());
		return "succ";
	}

}
